package com.hangim.pce.enums;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.google.common.collect.Lists;

import java.util.List;

/**
 * 人群类型
 */
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum PeopleType {
    ADULT("ADULT", 1, "成人"),
    SENIOR("SENIOR", 2, "老人"),
    PREGNANT("PREGNANT", 3, "孕妇"),
    BABY("BABY", 4, "新生儿婴儿婴幼儿"),
    NURSING("NURSING", 5, "小儿"),
    NONAGE("NONAGE", 6, "未成年人"),
    DIABETES("DIABETES", 7, "糖尿病"),
    HYPERTENSION("HYPERTENSION", 8, "高血压"),
    GESTATION("GESTATION", 9, "妊娠"),
    LACTATION("LACTATION", 10, "哺乳"),
    ATHLETE("ATHLETE", 11, "运动员"),
    HEPATIC_IMPAIRMENT("HEPATIC_IMPAIRMENT", 12, "肝损"),
    RENAL_IMPAIRMENT("RENAL_IMPAIRMENT", 13, "肾损"),
    CHILDREN("CHILDREN", 14, "儿童"),
    GLAUCOMA("GLAUCOMA", 15, "青光眼"),
    HYPOKALEMIA("HYPOKALEMIA", 16, "低钾血症"),
    HYPERNATREMIA("HYPERNATREMIA", 17, "高钠血症"),
    HEART_FAILURE("HEART_FAILURE", 18, "心力衰竭"),
    KIDNEY_FAILURE("KIDNEY_FAILURE", 19, "肾功能衰竭"),
    ILEUS("ILEUS", 20, "肠梗阻"),
    GASTROINTESTINAL_BLEEDING("GASTROINTESTINAL_BLEEDING", 21, "胃肠道出血"),
    MENSTRUAL_PERIOD("MENSTRUAL_PERIOD", 22, "妇女经期"),
    ALLERGIC_CONSTITUTION("ALLERGIC_CONSTITUTION", 23, "过敏体质"),
    COLD("COLD", 24, "伤风感冒"),
    NEPHROTIC_SYNDROME("NEPHROTIC_SYNDROME", 25, "肾病综合征"),
    VASCULAR_THROMBOSIS("VASCULAR_THROMBOSIS", 26, "血管栓塞"),
    THROMBOPHLEBITIS("THROMBOPHLEBITIS", 27, "血栓性静脉炎"),
    STROKE("STROKE", 28, "脑中风"),
    BREAST_NEOPLASMS("BREAST_NEOPLASMS", 29, "乳腺肿瘤"),
    GENITAL_NEOPLASMS("GENITAL_NEOPLASMS", 30, "生殖器肿瘤"),
    CARDIOPATHY("CARDIOPATHY", 31, "心脏病"),
    PARKINSONISM("PARKINSONISM", 32, "帕金森症"),
    HYPERTHYROIDISM("HYPERTHYROIDISM", 33, "甲状腺功能亢进症"),
    ARRHYTHMIA("ARRHYTHMIA", 31, "心律失常"),
    EPILEPSY("EPILEPSY", 32, "癫痫"),
    STENOCARDIA("STENOCARDIA", 33, "心绞痛"),
    THALASSEMIA("THALASSEMIA", 34, "地中海贫血"),
    WIND_FEVER("WIND_FEVER", 35, "风热者"),
    TOXIC_ENTERITIS("TOXIC_ENTERITIS", 36, "中毒性肠炎"),
    DIGESTIVE_TRACTHEMORRHAGE("DIGESTIVE_TRACTHEMORRHAGE", 37, "消化道出血"),
    TOXIC_MEGACOLON("TOXIC_MEGACOLON", 38, "中毒性巨结肠"),
    CORONARY_HEART_DISEASE("CORONARY_HEART_DISEASE", 39, "冠心病"),
    HEART_DAMAGE("HEART_DAMAGE", 40, "心损"),
    HEPATOPATHY("HEPATOPATHY", 41, "肝病"),
    OTHER("OTHER", 0, "其他");


    // 类型
    private final String code;
    // 描述
    private final String desc;
    // 编号
    private final Integer num;

    PeopleType(final String code, final Integer num, final String desc) {
        this.code = code;
        this.desc = desc;
        this.num = num;
    }

    /**
     * 把所有枚举定义转换成实体
     *
     * @return List<PeopleType>
     */
    public static List<PeopleType> getList() {
        List<PeopleType> list = Lists.newArrayList();

        PeopleType[] ts = PeopleType.values();
        for (PeopleType type : ts) {
            list.add(type);
        }
        return list;
    }

    public static PeopleType getPeopleType(String code) {
        PeopleType[] ts = PeopleType.values();
        for (PeopleType t : ts) {
            if (t.getCode().equalsIgnoreCase(code)) {
                return t;
            }
        }
        return OTHER;
    }

    public static PeopleType getPeopleTypeByDesc(String desc) {
        PeopleType[] ts = PeopleType.values();
        for (PeopleType t : ts) {
            if (t.getDesc().contains(desc)) {
                return t;
            }
        }
        return OTHER;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public Integer getNum() {
        return num;
    }
}
